﻿/*
    这个表可以从server的t_exchange表获得,可以算出在某个交易所产生了多少的盈利或返还等
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Benefit.Service.Sys
{
    /// <summary>
    /// 交易所表
    /// </summary>
    public class ServiceExchange : Benefit.Interface.Sys.IExchange
    {
        Benefit.DB.DBManager db = null;
        public ServiceExchange(Benefit.DB.DBManager db)
        {
            this.db = db;
        }

        /// <summary>
        /// 获取所有交易所
        /// </summary>
        /// <returns></returns>
        public List<Models.Sys.Exchange> GetList()
        {
            var query = db.Exchange.ToList();
            return query;
        }
        /// <summary>
        /// 存储一个交易所
        /// </summary>
        /// <param name="exchangeId"></param>
        /// <param name="exchangeName"></param>
        /// <returns></returns>
        public int InsertIntoBenefitFromServer(string exchangeId, string exchangeName)
        {
            Models.Sys.Exchange change = new Models.Sys.Exchange();
            change.ExchangeId = exchangeId;
            change.ExchangeName = exchangeName;
            db.Exchange.Add(change);
            db.SaveChanges();
            int id = change.Id;
            return id;
        }
    }
}